﻿namespace Demo.Permissions;

/// <summary>
/// 自定义权限特性
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class CusPermissionAttribute : Attribute
{
    /// <summary>
    /// 权限编码
    /// </summary>
    public string[] PermissionCode { get; }

    /// <summary>
    /// 权限之间的关系
    /// </summary>
    public PermissionRelation Relation { get; } = PermissionRelation.And;
        

    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="relation">权限关系</param>
    /// <param name="permissionCodes">权限编码</param>
    public CusPermissionAttribute(PermissionRelation relation,params string[] permissionCodes)
    {
        Relation = relation;
        PermissionCode = permissionCodes;
    }
        
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="permissionCodes">权限编码</param>
    public CusPermissionAttribute(params string[] permissionCodes)
    {
        PermissionCode = permissionCodes;
    }
}